package com.manager.service.serviceConfig.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.manager.model.CustomerType;
import com.manager.service.serviceConfig.mapper.TypeMapper;
import com.manager.service.serviceConfig.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.manager.model.CustomerType;


/**
* @author pooh
* @description 针对表【type】的数据库操作Service实现
* @createDate 2023-03-19 12:45:43
*/
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, CustomerType>
    implements TypeService {
    @Autowired
    TypeMapper typeMapper;
    @Override
    public boolean addType(String content) {
        CustomerType customerType = typeMapper.searchByName(content);
        if(customerType == null){
            CustomerType type = new CustomerType();
            type.setName(content);
            type.setStatus(1);
            this.save(type);
        }else{
            if(customerType.getStatus() == 0){
                customerType.setName(content);
                customerType.setStatus(1);
                this.updateById(customerType);
            }else{
                return false;
            }
        }
        return true;
    }
}




